package com.example.bnuzzu.common.dto;
import cn.hutool.core.lang.Assert;
import lombok.Data;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
public class HouseDto implements Serializable {
    private String houseid;

    private String housename;

    private String userid;

    private String username;

    private String limited;

    private String friends;

    private String phone;

    private String updatetime;

    private String catgoryid;

    private String deleted;

    private String region;

    private String regionid;

    private String address;

    private String area;

    private String price;

    private String floor;

    private String orientation;

    private String description;

    private String housestate;

    private String lobby;

    private String room;

    private String wc;

    private String[] images;

    private Boolean refrigerator = false;

    private Boolean sofa = false;

    private Boolean wardrobe = false;

    private Boolean bed = false;

    private Boolean airconditioner = false;

    private Boolean washingmachine = false;

    private Boolean balcony = false;

    private Boolean internet = false;

    private Boolean tv = false;

    private Boolean waterheater = false;

    private Boolean elevator = false;

    private String[] facilities;

    public void fillFa(){
        for (String facility : facilities) {
            switch (facility) {
                case "冰箱" -> this.refrigerator = true;
                case "空调" -> this.airconditioner = true;
                case "沙发" -> this.sofa = true;
                case "衣柜" -> this.wardrobe = true;
                case "床"   -> this.bed=true;
                case "阳台" -> this.balcony = true;
                case "洗衣机"-> this.washingmachine = true;
                case "互联网" -> this.internet = true;
                case "电视" -> this.tv = true;
                case "热水器" -> this.waterheater = true;
                case "电梯" -> this.elevator = true;
                default-> System.out.println(facility);
            }
        }
    }

    public void splitFa(){
        List<String> list=new ArrayList<>();

       if(airconditioner){
            list.add("空调");
        }
        if(balcony){
            list.add("阳台");
        }
         if(bed){
            list.add("床");
        }
        if(elevator){
            list.add("电梯");
        }
         if(waterheater){
            list.add("热水器");
        }
         if(internet){
            list.add("互联网");
        }
        if(refrigerator){
            list.add("冰箱");
        }
        if(sofa){
            list.add("沙发");
        }
         if(tv){
            list.add("电视");
        }
        if(wardrobe){
            list.add("衣柜");
        }
        if(washingmachine){
            list.add("洗衣机");
        }

        int size=list.size();
        this.facilities = list.toArray(new String[size]);
    }
}
